<template>
  <div class="wrapper">
    <swiper
      :options="swiperOption"
      v-if="showSwiper"
    >
      <swiper-slide
        v-for="item of swiperList"
        :key="item.id"
      >
        <img
          class="swiper-img"
          :src="item.imgUrl"
        />
      </swiper-slide>

      <div
        class="swiper-pagination"
        slot="pagination"
      ></div>
    </swiper>
  </div>

</template>
<script>
export default {
  name: 'HomeSwiper',
  props: {
    swiperList: Array
  },
  computed: {
    showSwiper () {
      return this.swiperList.length
    }
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        loop: true
      }
      // swiperList: [
      //   {
      //     id: '0001',
      //     imgUrl: 'https://mp-piao-admincp.qunarzz.com/mp_piao_admin_mp_piao_admin/admin/20196/1a77cfc99bdf951b099c2c963729546b.jpg_890x330_3b8b02bb.jpg'
      //   },
      //   {
      //     id: '0002',
      //     imgUrl: 'https://mp-piao-admincp.qunarzz.com/mp_piao_admin_mp_piao_admin/admin/20199/b73102b25b3249fc3724ef5c61c93b87.jpg_890x330_bd218488.jpg'
      //   }
      // ]
    }
  }
}
</script>
<style lang="stylus" scoped>
.wrapper >>> .swiper-pagination-bullet-active {
  background-color: red;
}
// 高除以宽是31.25的比例,用来占位 height:31.25vm 有些浏览器兼容不行
.wrapper {
  //
  overflow: hidden;
  width: 100%;
  height: 0;
  padding-bottom: 31.25%;
  background-color: #eee;
  //
  .swiper-img {
    width: 100%;
  }
}
</style>
